#include <cstdio>
float aver(float *pa) {
  int i;
  float av, s = 0;
  for (i = 0; i < 5; i++)
    s = s + *pa++;
  av = s / 5;
  return av;
}

void print_pointer() {
  int a1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
  int b1[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
  int *p = a1;
  //%p打印地址（指针地址），是十六进制的形式
  printf("%p,", a1);
  // 数组名是一个常量指针，指向数组的首元素，并且不能改变指向（即不能作为左值进行赋值操作）。
  //  a1 = b1;
  printf("%d,", *a1);
  p = b1;
  printf("%d,", *p);
  printf("\n二维数组:\n");

  int a[3][4] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
  //%p打印地址（指针地址），是十六进制的形式
  printf("%p,", a);
  printf("%p,", *a);
  printf("%p,", a[0]);
  printf("%p,", &a[0]);
  printf("%p\n", &a[0][0]);
  printf("%d\n", a[0][0]); // 取值
  printf("%p,", a + 1);
  printf("%p,", *(a + 1));
  printf("%p,", a[1]);
  printf("%p,", &a[1]);
  printf("%p\n", &a[1][0]);
  printf("%p,", a + 2);
  printf("%p,", *(a + 2));
  printf("%p,", a[2]);
  printf("%p,", &a[2]);
  printf("%p\n", &a[2][0]);
  printf("%p,", a[1] + 1);
  printf("%p\n", *(a + 1) + 1);
  printf("%d,%d\n", *(a[1] + 1), *(*(a + 1) + 1));
}
int main() {
  float av, *sp;
  float sco[5] = {1.0, 2., 3., 4., 5.};
  float *p = sco + 1;
  printf("%f", *p);
  sp = sco;
  av = aver(sp);
  printf("average score is %5.2f\n", av);
  print_pointer();
}
